import { useState,createContext, ReactNode, useMemo, useContext } from "react";

const IsOpenScreen = createContext({
    isOpen: false,
    setIsOpen: (open:boolean) => {}
})
export const IsOpenScreenProvider = ({children}:{children:ReactNode}) => {
    const [isOpen, setIsOpen] = useState<boolean>(false)
    const contextValue:any = useMemo(() => ({
        isOpen,
        setIsOpen
    }), [isOpen]);
    return <IsOpenScreen.Provider value={contextValue}>
        {children}
    </IsOpenScreen.Provider>
}
const useScreen = () => {
    const context = useContext(IsOpenScreen)
    return context;
}

export default useScreen